//page gui
function bindPa(li){
	
	try{
		　$("#table1_tmpl").tmpl(li).appendTo('#table1');
	//	alert("ok");
	}catch(e){  showErr(e);
	}
	};

function menu_click2(cate)
{
	 $("#doc-oc-demo2").offCanvas('close');
	  $("#wrapper").css("margin-top","0px");
 get_posts({"cate":cate});	

}

function clr_list_area()
{
$("#table1").html("");	
 

}

function page_load()
{
/*var o={	pagesize:3,keyword:"",rows:arr,bind_handler:bindPa};
	//page gui
	//alert(listPaf2);
	 listPaf2(o);*/
	 try{
		 
		 setPageSpy();
	 next_click();
	 next_click();
		 
	$("#table1_tmpl").hide();	
	
	iniMenuEvent();
	
	
	 }catch(e)
	 {
		showErr(e); 
	 }
}

function iniMenuEvent()
{
$("#left_menu_div span").each(function(index, element) {
    $(element).click(function(){
		var cate=$(this).text();
		menu_click2(cate);
		
	});
	
});
	
}

$.fn.isOnScreen = function(){
     
    var win = $(window);
     
    var viewport = {
        top : win.scrollTop(),
        left : win.scrollLeft()
    };
    viewport.right = viewport.left + win.width();
    viewport.bottom = viewport.top + win.height();
     
    var bounds = this.offset();
    bounds.right = bounds.left + this.outerWidth();
    bounds.bottom = bounds.top + this.outerHeight();
     
    return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
     
};

$(function() {
	
//	menu_click2("爱情类");
window.setInterval(function(){
	var rzt=$("#scrool_spy").isOnScreen();
	if(rzt)
		next_click();
	console.log( "visible spy::"+rzt);
	},500);

	});